package com.qingmu.club.minaapi.controller.member;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qingmu.club.minaapi.plus.entity.Activity;
import com.qingmu.club.minaapi.plus.entity.Banner;
import com.qingmu.club.minaapi.plus.entity.ClubUsersIntegral;
import com.qingmu.club.minaapi.plus.service.ActivityService;
import com.qingmu.club.minaapi.plus.service.BannerService;
import com.qingmu.club.minaapi.utils.ResponseObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 活动主表 前端控制器
 * </p>
 *
 * @author duke
 * @since 2019-08-20
 */
@RestController
@CrossOrigin(origins = "*", methods = {RequestMethod.POST, RequestMethod.GET})
@Api(value = "首页banner相关(会员端小程序)", description = "首页banner相关(会员端小程序)")
@RequestMapping("/member/banner")
public class MemberBannerController {

    @Autowired
    BannerService bannerService;

    @RequestMapping(value = "/selectHomePage", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "首页banner图")
    public ResponseEntity selectHomePage() {

        QueryWrapper<Banner> qw = new QueryWrapper<>();
        qw.eq(Banner.STATUS, 1)
                .eq(Banner.BANNER_TYPE,0)
                .orderByDesc(Banner.CREATE_TIME);
        List<Banner> bannerList  = bannerService.list(qw);

        return ResponseObject.success(bannerList);
    }


    @RequestMapping(value = "/selectCourse", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ApiOperation(value = "课程banner图")
    public ResponseEntity selectCourse(
            @ApiParam(required = true, value = "门店id") @RequestParam(required = true) String shopId

    ) {

        QueryWrapper<Banner> qw = new QueryWrapper<>();
        qw.eq(Banner.STATUS, 1)
                .eq(Banner.BANNER_TYPE,1)
                .eq(Banner.SHOP_ID, shopId)
                .orderByDesc(Banner.CREATE_TIME);
        List<Banner> bannerList  = bannerService.list(qw);

        return ResponseObject.success(bannerList);
    }
}

